"""
1.json必须有一个{}
2.他的key一般情况下是字符串
3.bool类型在json中首字母小写

"""
import json

# json转换成python对象  通过json.load()
with open('a.json', 'r',encoding='utf-8') as f:
    data = json.load(f)
    # data = json.loads(f.read())
    print(type(data))
    print(data)

# python对象转换成json 通过json.dump()
data = {
    "name": "张三",
    "age": 18,
    "is_married": True
}
# 默认中文会被转换成unicode(ascii码)防止中文乱码
with open('b.json', 'w',encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False)
